<template>
  <div>
    <van-nav-bar
      :title="title"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />
    <h3>order订单详情</h3>
  </div>
</template>

<script>
import { Toast, NavBar } from 'vant'

export default {
  name: 'order',
  components: {
    [NavBar.name]: NavBar
  },
  data () {
    return {
      orderId: null,
      order: null
    }
  },
  async mounted () {
    this.orderId = this.$route.params.orderId
  },
  async activated () {
    await this.getOrder(this.orderId)
  },
  computed: {
    title () {
      if (this.order == null) {
        return '订单详情'
      }
      return this.order.id
    }
  },
  methods: {
    async getOrder (id) {
      try {
        const { data } = await this.$api.bet.orderDetail(id)
        console.log(data)
        if (data.code === 200) {
          this.order = data.data
        } else {
          Toast('获取数据失败，请刷新')
        }
      } catch (e) {
        Toast('获取数据失败，请刷新')
      }
    },
    onClickLeft () {
      this.$router.go(-1)
    }
  }
}
</script>

<style scoped>

</style>
